
local serviceId
function OnInit(id)
    print("[lua] pong["..id.."] OnInit")
    serviceId = id
end

function OnServiceMsg(source, buff)
    print("[lua] pong["..serviceId.."] OnServiceMsg buff="..buff)
    local num = tonumber(buff)
    if num > 3 then
        sunnet.KillService(serviceId)
        return
    end
    sunnet.Send(serviceId, source, tostring(num+1))
end

function OnExit()
    print("[lua] pong["..serviceId.."] OnExit")
end